﻿using System;
using System.Data;
using System.Configuration;
using System.Web;

using System.Collections.Generic;
using System.Text;
namespace LearnNet.Common.RegExpression
{
    /// <summary>
    ///用于保存计算过程的中间结果及当前执行的操作
    /// </summary>
    public class RegContext
    {
        public RegContext() { }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="_content">文本内容</param>
        /// <param name="_operator"> M is Matches ;R is Replace</param>
        /// <param name="replacement">用于替换的文本内容</param>
        public RegContext(string _context,char _operator,string _replacement)
        {
            this.Context = _context;
            this.Operator = _operator;
            this.Replacement = _replacement;
        }

        /// <summary>
        /// 文本内容
        /// </summary>
        public string Context;

        /// <summary>
        /// M is Matches ;R is Replace
        /// </summary>
        public char Operator;

        /// <summary>
        /// 用于匹配字符串的集合
        /// </summary>
        public IList<string> Matches = new List<string>();

        /// <summary>
        /// 返回所匹配值的字符串连接
        /// </summary>
        /// <returns></returns>
        public string ToString()
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < Matches.Count; i++)
            {
                sb.Append(Matches[i]);
            }
            return sb.ToString();
        }
        /// <summary>
        /// 用于替换的文本内容
        /// </summary>
        public string Replacement;
    }
}
